﻿using System;
using System.Collections.Generic;
using System.Linq;
using Helpers;
using TaleWorlds.CampaignSystem.Actions;
using TaleWorlds.CampaignSystem.CharacterDevelopment;
using TaleWorlds.CampaignSystem.Conversation;
using TaleWorlds.CampaignSystem.Extensions;
using TaleWorlds.CampaignSystem.MapEvents;
using TaleWorlds.CampaignSystem.Party;
using TaleWorlds.CampaignSystem.Roster;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.Core;
using TaleWorlds.Library;
using TaleWorlds.Localization;
using TaleWorlds.ObjectSystem;
using TaleWorlds.SaveSystem;

namespace TaleWorlds.CampaignSystem.Issues
{
	// Token: 0x02000310 RID: 784
	public class LandlordTrainingForRetainersIssueBehavior : CampaignBehaviorBase
	{
		// Token: 0x06002D5B RID: 11611 RVA: 0x000BDCC5 File Offset: 0x000BBEC5
		public override void RegisterEvents()
		{
			CampaignEvents.OnCheckForIssueEvent.AddNonSerializedListener(this, new Action<Hero>(this.OnCheckForIssue));
		}

		// Token: 0x06002D5C RID: 11612 RVA: 0x000BDCDE File Offset: 0x000BBEDE
		public override void SyncData(IDataStore dataStore)
		{
		}

		// Token: 0x06002D5D RID: 11613 RVA: 0x000BDCE0 File Offset: 0x000BBEE0
		private bool ConditionsHold(Hero issueGiver)
		{
			Settlement currentSettlement = issueGiver.CurrentSettlement;
			ItemObject itemObject;
			if (currentSettlement == null)
			{
				itemObject = null;
			}
			else
			{
				Village village = currentSettlement.Village;
				if (village == null)
				{
					itemObject = null;
				}
				else
				{
					VillageType villageType = village.VillageType;
					itemObject = ((villageType != null) ? villageType.PrimaryProduction : null);
				}
			}
			ItemObject itemObject2 = itemObject;
			return issueGiver.IsRuralNotable && issueGiver.CurrentSettlement.IsVillage && itemObject2.HasHorseComponent && (itemObject2.ItemCategory == DefaultItemCategories.Horse || itemObject2.ItemCategory == DefaultItemCategories.NobleHorse || itemObject2.ItemCategory == DefaultItemCategories.WarHorse);
		}

		// Token: 0x06002D5E RID: 11614 RVA: 0x000BDD60 File Offset: 0x000BBF60
		public void OnCheckForIssue(Hero hero)
		{
			if (this.ConditionsHold(hero))
			{
				Campaign.Current.IssueManager.AddPotentialIssueData(hero, new PotentialIssueData(new PotentialIssueData.StartIssueDelegate(this.OnSelected), typeof(LandlordTrainingForRetainersIssueBehavior.LandlordTrainingForRetainersIssue), IssueBase.IssueFrequency.VeryCommon, null));
				return;
			}
			Campaign.Current.IssueManager.AddPotentialIssueData(hero, new PotentialIssueData(typeof(LandlordTrainingForRetainersIssueBehavior.LandlordTrainingForRetainersIssue), IssueBase.IssueFrequency.VeryCommon));
		}

		// Token: 0x06002D5F RID: 11615 RVA: 0x000BDDC4 File Offset: 0x000BBFC4
		private IssueBase OnSelected(in PotentialIssueData pid, Hero issueOwner)
		{
			return new LandlordTrainingForRetainersIssueBehavior.LandlordTrainingForRetainersIssue(issueOwner);
		}

		// Token: 0x04000D95 RID: 3477
		private const IssueBase.IssueFrequency LandlordTrainingForRetainersIssueFrequency = IssueBase.IssueFrequency.VeryCommon;

		// Token: 0x02000644 RID: 1604
		public class LandlordTrainingForRetainersIssue : IssueBase
		{
			// Token: 0x06004F1E RID: 20254 RVA: 0x001698BE File Offset: 0x00167ABE
			internal static void AutoGeneratedStaticCollectObjectsLandlordTrainingForRetainersIssue(object o, List<object> collectedObjects)
			{
				((LandlordTrainingForRetainersIssueBehavior.LandlordTrainingForRetainersIssue)o).AutoGeneratedInstanceCollectObjects(collectedObjects);
			}

			// Token: 0x06004F1F RID: 20255 RVA: 0x001698CC File Offset: 0x00167ACC
			protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
			{
				base.AutoGeneratedInstanceCollectObjects(collectedObjects);
			}

			// Token: 0x1700106D RID: 4205
			// (get) Token: 0x06004F20 RID: 20256 RVA: 0x001698D5 File Offset: 0x00167AD5
			public override IssueBase.AlternativeSolutionScaleFlag AlternativeSolutionScaleFlags
			{
				get
				{
					return IssueBase.AlternativeSolutionScaleFlag.Casualties | IssueBase.AlternativeSolutionScaleFlag.FailureRisk;
				}
			}

			// Token: 0x1700106E RID: 4206
			// (get) Token: 0x06004F21 RID: 20257 RVA: 0x001698D9 File Offset: 0x00167AD9
			private int BorrowedTroopCount
			{
				get
				{
					return 3 + MathF.Ceiling(17f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x1700106F RID: 4207
			// (get) Token: 0x06004F22 RID: 20258 RVA: 0x001698EE File Offset: 0x00167AEE
			protected override bool IssueQuestCanBeDuplicated
			{
				get
				{
					return false;
				}
			}

			// Token: 0x17001070 RID: 4208
			// (get) Token: 0x06004F23 RID: 20259 RVA: 0x001698F1 File Offset: 0x00167AF1
			public override int AlternativeSolutionBaseNeededMenCount
			{
				get
				{
					return 8 + MathF.Ceiling(19f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x17001071 RID: 4209
			// (get) Token: 0x06004F24 RID: 20260 RVA: 0x00169906 File Offset: 0x00167B06
			protected override int AlternativeSolutionBaseDurationInDaysInternal
			{
				get
				{
					return 9 + MathF.Ceiling(10f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x17001072 RID: 4210
			// (get) Token: 0x06004F25 RID: 20261 RVA: 0x0016991C File Offset: 0x00167B1C
			protected override int RewardGold
			{
				get
				{
					return (int)(2000f + 4000f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x17001073 RID: 4211
			// (get) Token: 0x06004F26 RID: 20262 RVA: 0x00169934 File Offset: 0x00167B34
			public override TextObject Title
			{
				get
				{
					TextObject textObject = new TextObject("{=q2aed7tv}Train troops for {ISSUE_OWNER.NAME}", null);
					StringHelpers.SetCharacterProperties("ISSUE_OWNER", base.IssueOwner.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x17001074 RID: 4212
			// (get) Token: 0x06004F27 RID: 20263 RVA: 0x00169968 File Offset: 0x00167B68
			public override TextObject Description
			{
				get
				{
					TextObject textObject = new TextObject("{=va7rEVZn}{ISSUE_OWNER.NAME}, a landowner in {ISSUE_SETTLEMENT}, needs some of his watchmen and retainers to gain some real war experience. {?ISSUE_OWNER.GENDER}She{?}He{\\?} wants you to take them with you on some fairly safe expeditions, such as hunting some bandits. ", null);
					StringHelpers.SetCharacterProperties("ISSUE_OWNER", base.IssueOwner.CharacterObject, textObject, false);
					textObject.SetTextVariable("ISSUE_SETTLEMENT", base.IssueSettlement.Name);
					return textObject;
				}
			}

			// Token: 0x17001075 RID: 4213
			// (get) Token: 0x06004F28 RID: 20264 RVA: 0x001699B1 File Offset: 0x00167BB1
			protected override int CompanionSkillRewardXP
			{
				get
				{
					return (int)(500f + 700f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x17001076 RID: 4214
			// (get) Token: 0x06004F29 RID: 20265 RVA: 0x001699C6 File Offset: 0x00167BC6
			public override TextObject IssueBriefByIssueGiver
			{
				get
				{
					return new TextObject("{=dBphGKTI}Things are getting a bit rough around these parts. I have some lads who help me out with local troublemakers, but they wouldn't last long against real warriors. Maybe you could take them out, show them what actual war is about. I'm not expecting you to make them fit for a noble's retinue, but at least I want to give the bandits around here some pause for thought.[if:convo_bored][ib:closed]", null);
				}
			}

			// Token: 0x17001077 RID: 4215
			// (get) Token: 0x06004F2A RID: 20266 RVA: 0x001699D3 File Offset: 0x00167BD3
			public override TextObject IssueAcceptByPlayer
			{
				get
				{
					return new TextObject("{=1REltXXz}I'll help if I can.", null);
				}
			}

			// Token: 0x17001078 RID: 4216
			// (get) Token: 0x06004F2B RID: 20267 RVA: 0x001699E0 File Offset: 0x00167BE0
			public override TextObject IssueQuestSolutionExplanationByIssueGiver
			{
				get
				{
					return new TextObject("{=uLiRasv1}Maybe you could take them in your party for a while, until they get a bit of experience?[if:convo_thinking]", null);
				}
			}

			// Token: 0x17001079 RID: 4217
			// (get) Token: 0x06004F2C RID: 20268 RVA: 0x001699ED File Offset: 0x00167BED
			public override TextObject IssueAlternativeSolutionExplanationByIssueGiver
			{
				get
				{
					return new TextObject("{=rutgr1VF}Or if you can assign a companion for a while, they can stay here and train the men... I will also give you some provisions and money for their expenses and your trouble.[if:convo_thinking]", null);
				}
			}

			// Token: 0x1700107A RID: 4218
			// (get) Token: 0x06004F2D RID: 20269 RVA: 0x001699FA File Offset: 0x00167BFA
			public override TextObject IssueQuestSolutionAcceptByPlayer
			{
				get
				{
					return new TextObject("{=QxEPwLyp}I'll take your men into my party and show them a bit of the world.", null);
				}
			}

			// Token: 0x1700107B RID: 4219
			// (get) Token: 0x06004F2E RID: 20270 RVA: 0x00169A07 File Offset: 0x00167C07
			public override TextObject IssueAlternativeSolutionAcceptByPlayer
			{
				get
				{
					return new TextObject("{=oT4JNyFp}I will assign one of my companions to train your men.", null);
				}
			}

			// Token: 0x1700107C RID: 4220
			// (get) Token: 0x06004F2F RID: 20271 RVA: 0x00169A14 File Offset: 0x00167C14
			public override TextObject IssueAlternativeSolutionResponseByIssueGiver
			{
				get
				{
					return new TextObject("{=dE3vxfTo}Excellent.[if:convo_focused_happy] I'm sure they can learn a lot from your veterans.", null);
				}
			}

			// Token: 0x1700107D RID: 4221
			// (get) Token: 0x06004F30 RID: 20272 RVA: 0x00169A21 File Offset: 0x00167C21
			public override TextObject IssueDiscussAlternativeSolution
			{
				get
				{
					return new TextObject("{=QRRgXOrN}As expected, your veterans have really sharpened up our boys. Please pass on my thanks to them, {?PLAYER.GENDER}madam{?}sir{\\?}.[if:convo_focused_happy][ib:hip]", null);
				}
			}

			// Token: 0x1700107E RID: 4222
			// (get) Token: 0x06004F31 RID: 20273 RVA: 0x00169A2E File Offset: 0x00167C2E
			public override bool IsThereAlternativeSolution
			{
				get
				{
					return true;
				}
			}

			// Token: 0x1700107F RID: 4223
			// (get) Token: 0x06004F32 RID: 20274 RVA: 0x00169A31 File Offset: 0x00167C31
			public override bool IsThereLordSolution
			{
				get
				{
					return false;
				}
			}

			// Token: 0x17001080 RID: 4224
			// (get) Token: 0x06004F33 RID: 20275 RVA: 0x00169A34 File Offset: 0x00167C34
			protected override TextObject AlternativeSolutionStartLog
			{
				get
				{
					TextObject textObject = new TextObject("{=Ci8NCwgW}{ISSUE_GIVER.LINK} a landowner in {SETTLEMENT}, asked you to train recruits for {?QUEST_GIVER.GENDER}her{?}him{\\?}. {?QUEST_GIVER.GENDER}She{?}He{\\?} gave you {NUMBER_OF_MEN} men, hoping to take them back when once they are veterans.{newline}You sent them with one of your companions {COMPANION.LINK} to hunt down some easy targets. You arranged to meet them in {RETURN_DAYS} days.", null);
					textObject.SetCharacterProperties("ISSUE_GIVER", base.IssueOwner.CharacterObject, false);
					textObject.SetCharacterProperties("COMPANION", base.AlternativeSolutionHero.CharacterObject, false);
					textObject.SetTextVariable("SETTLEMENT", base.IssueOwner.CurrentSettlement.EncyclopediaLinkWithName);
					textObject.SetTextVariable("RETURN_DAYS", base.GetTotalAlternativeSolutionDurationInDays());
					textObject.SetTextVariable("NUMBER_OF_MEN", base.GetTotalAlternativeSolutionNeededMenCount());
					return textObject;
				}
			}

			// Token: 0x17001081 RID: 4225
			// (get) Token: 0x06004F34 RID: 20276 RVA: 0x00169ABC File Offset: 0x00167CBC
			public override TextObject IssueAlternativeSolutionSuccessLog
			{
				get
				{
					TextObject textObject = new TextObject("{=AndfZYIJ}Your companion managed to return all of the troops {ISSUE_GIVER.LINK} gave you to train. {?ISSUE_GIVER.GENDER}She{?}He{\\?} sends you the following letter.\n\n“{?PLAYER.GENDER}Madam{?}Sir{\\?}, Thank you for looking after my men. You honored our agreement, and you have my gratitude. Please accept this {GOLD}{GOLD_ICON}.", null);
					textObject.SetCharacterProperties("ISSUE_GIVER", base.IssueOwner.CharacterObject, false);
					textObject.SetCharacterProperties("PLAYER", CharacterObject.PlayerCharacter, false);
					textObject.SetTextVariable("GOLD", this.RewardGold);
					textObject.SetTextVariable("GOLD_ICON", "{=!}<img src=\"General\\Icons\\Coin@2x\" extend=\"8\">");
					return textObject;
				}
			}

			// Token: 0x06004F35 RID: 20277 RVA: 0x00169B1F File Offset: 0x00167D1F
			public LandlordTrainingForRetainersIssue(Hero issueOwner) : base(issueOwner, CampaignTime.DaysFromNow(30f))
			{
			}

			// Token: 0x06004F36 RID: 20278 RVA: 0x00169B32 File Offset: 0x00167D32
			protected override float GetIssueEffectAmountInternal(IssueEffect issueEffect)
			{
				if (issueEffect == DefaultIssueEffects.SettlementSecurity)
				{
					return -1f;
				}
				return 0f;
			}

			// Token: 0x06004F37 RID: 20279 RVA: 0x00169B47 File Offset: 0x00167D47
			public override ValueTuple<SkillObject, int> GetAlternativeSolutionSkill(Hero hero)
			{
				return new ValueTuple<SkillObject, int>((hero.GetSkillValue(DefaultSkills.Steward) >= hero.GetSkillValue(DefaultSkills.Leadership)) ? DefaultSkills.Steward : DefaultSkills.Leadership, 120);
			}

			// Token: 0x06004F38 RID: 20280 RVA: 0x00169B74 File Offset: 0x00167D74
			public override bool AlternativeSolutionCondition(out TextObject explanation)
			{
				explanation = TextObject.Empty;
				return QuestHelper.CheckRosterForAlternativeSolution(MobileParty.MainParty.MemberRoster, base.GetTotalAlternativeSolutionNeededMenCount(), ref explanation, 2, false);
			}

			// Token: 0x06004F39 RID: 20281 RVA: 0x00169B95 File Offset: 0x00167D95
			protected override void AlternativeSolutionEndWithSuccessConsequence()
			{
				this.RelationshipChangeWithIssueOwner = 5;
				base.IssueOwner.AddPower(10f);
			}

			// Token: 0x06004F3A RID: 20282 RVA: 0x00169BAE File Offset: 0x00167DAE
			protected override void AlternativeSolutionEndWithFailureConsequence()
			{
				this.RelationshipChangeWithIssueOwner = -5;
				base.IssueOwner.AddPower(-10f);
			}

			// Token: 0x06004F3B RID: 20283 RVA: 0x00169BC8 File Offset: 0x00167DC8
			public override bool DoTroopsSatisfyAlternativeSolution(TroopRoster troopRoster, out TextObject explanation)
			{
				explanation = TextObject.Empty;
				return QuestHelper.CheckRosterForAlternativeSolution(troopRoster, base.GetTotalAlternativeSolutionNeededMenCount(), ref explanation, 2, false);
			}

			// Token: 0x06004F3C RID: 20284 RVA: 0x00169BE0 File Offset: 0x00167DE0
			public override bool IsTroopTypeNeededByAlternativeSolution(CharacterObject character)
			{
				return character.Tier >= 2;
			}

			// Token: 0x06004F3D RID: 20285 RVA: 0x00169BEE File Offset: 0x00167DEE
			public override IssueBase.IssueFrequency GetFrequency()
			{
				return IssueBase.IssueFrequency.VeryCommon;
			}

			// Token: 0x06004F3E RID: 20286 RVA: 0x00169BF1 File Offset: 0x00167DF1
			public override bool IssueStayAliveConditions()
			{
				return !base.IssueOwner.CurrentSettlement.IsRaided && !base.IssueOwner.CurrentSettlement.IsUnderRaid;
			}

			// Token: 0x06004F3F RID: 20287 RVA: 0x00169C1A File Offset: 0x00167E1A
			protected override void CompleteIssueWithTimedOutConsequences()
			{
			}

			// Token: 0x06004F40 RID: 20288 RVA: 0x00169C1C File Offset: 0x00167E1C
			protected override void OnGameLoad()
			{
			}

			// Token: 0x06004F41 RID: 20289 RVA: 0x00169C1E File Offset: 0x00167E1E
			protected override void HourlyTick()
			{
			}

			// Token: 0x06004F42 RID: 20290 RVA: 0x00169C20 File Offset: 0x00167E20
			protected override QuestBase GenerateIssueQuest(string questId)
			{
				return new LandlordTrainingForRetainersIssueBehavior.LandlordTrainingForRetainersIssueQuest(questId, base.IssueOwner, CampaignTime.DaysFromNow(60f), base.IssueDifficultyMultiplier, this.RewardGold);
			}

			// Token: 0x06004F43 RID: 20291 RVA: 0x00169C44 File Offset: 0x00167E44
			protected override bool CanPlayerTakeQuestConditions(Hero issueGiver, out IssueBase.PreconditionFlags flag, out Hero relationHero, out SkillObject skill)
			{
				skill = null;
				relationHero = null;
				flag = IssueBase.PreconditionFlags.None;
				if (issueGiver.GetRelationWithPlayer() < -10f)
				{
					flag |= IssueBase.PreconditionFlags.Relation;
					relationHero = issueGiver;
				}
				if (FactionManager.IsAtWarAgainstFaction(issueGiver.CurrentSettlement.MapFaction, Hero.MainHero.MapFaction))
				{
					flag |= IssueBase.PreconditionFlags.AtWar;
				}
				if (MobileParty.MainParty.MemberRoster.TotalManCount + this.BorrowedTroopCount > PartyBase.MainParty.PartySizeLimit)
				{
					flag |= IssueBase.PreconditionFlags.PartySizeLimit;
				}
				return flag == IssueBase.PreconditionFlags.None;
			}

			// Token: 0x06004F44 RID: 20292 RVA: 0x00169CC8 File Offset: 0x00167EC8
			private int GetTier2TroopCount(TroopRoster troopRoster)
			{
				int num = 0;
				foreach (TroopRosterElement troopRosterElement in troopRoster.GetTroopRoster())
				{
					if (troopRosterElement.Character.Tier >= 2 && !troopRosterElement.Character.IsNotTransferableInPartyScreen)
					{
						num += troopRoster.GetTroopCount(troopRosterElement.Character);
					}
				}
				return num;
			}

			// Token: 0x04001A41 RID: 6721
			private const int QuestTimeLimit = 60;

			// Token: 0x04001A42 RID: 6722
			private const int IssueDuration = 30;

			// Token: 0x04001A43 RID: 6723
			private const int AlternativeSolutionTroopTierRequirement = 2;

			// Token: 0x04001A44 RID: 6724
			private const int SkillLimit = 120;
		}

		// Token: 0x02000645 RID: 1605
		public class LandlordTrainingForRetainersIssueQuest : QuestBase
		{
			// Token: 0x06004F45 RID: 20293 RVA: 0x00169D44 File Offset: 0x00167F44
			internal static void AutoGeneratedStaticCollectObjectsLandlordTrainingForRetainersIssueQuest(object o, List<object> collectedObjects)
			{
				((LandlordTrainingForRetainersIssueBehavior.LandlordTrainingForRetainersIssueQuest)o).AutoGeneratedInstanceCollectObjects(collectedObjects);
			}

			// Token: 0x06004F46 RID: 20294 RVA: 0x00169D52 File Offset: 0x00167F52
			protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
			{
				base.AutoGeneratedInstanceCollectObjects(collectedObjects);
				collectedObjects.Add(this._playerStartsQuestLog);
			}

			// Token: 0x06004F47 RID: 20295 RVA: 0x00169D67 File Offset: 0x00167F67
			internal static object AutoGeneratedGetMemberValue_difficultyMultiplier(object o)
			{
				return ((LandlordTrainingForRetainersIssueBehavior.LandlordTrainingForRetainersIssueQuest)o)._difficultyMultiplier;
			}

			// Token: 0x06004F48 RID: 20296 RVA: 0x00169D79 File Offset: 0x00167F79
			internal static object AutoGeneratedGetMemberValue_playerStartsQuestLog(object o)
			{
				return ((LandlordTrainingForRetainersIssueBehavior.LandlordTrainingForRetainersIssueQuest)o)._playerStartsQuestLog;
			}

			// Token: 0x17001082 RID: 4226
			// (get) Token: 0x06004F49 RID: 20297 RVA: 0x00169D86 File Offset: 0x00167F86
			private int _borrowedTroopCount
			{
				get
				{
					return 3 + MathF.Ceiling(17f * this._difficultyMultiplier);
				}
			}

			// Token: 0x17001083 RID: 4227
			// (get) Token: 0x06004F4A RID: 20298 RVA: 0x00169D9C File Offset: 0x00167F9C
			private TextObject _questStartLog
			{
				get
				{
					TextObject textObject = new TextObject("{=fcRLq8LL}{QUEST_GIVER.LINK}, a landowner in {QUEST_SETTLEMENT}, asked you to train some recruits for {?QUEST_GIVER.GENDER}her{?}him{\\?}. {?QUEST_GIVER.GENDER}She{?}He{\\?} gave you {NUMBER_OF_MEN} men, hoping to take them back when once they have some experience.\nThe easiest way to train them without putting them in too much danger is to attack weak parties.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					textObject.SetTextVariable("QUEST_SETTLEMENT", base.QuestGiver.CurrentSettlement.Name);
					textObject.SetTextVariable("NUMBER_OF_MEN", this._borrowedTroopCount);
					return textObject;
				}
			}

			// Token: 0x17001084 RID: 4228
			// (get) Token: 0x06004F4B RID: 20299 RVA: 0x00169DFC File Offset: 0x00167FFC
			private TextObject _totalSuccessLog
			{
				get
				{
					TextObject textObject = new TextObject("{=4RNREbPW}You managed to return all of the troops {QUEST_GIVER.LINK} gave you to train. {?QUEST_GIVER.GENDER}She{?}He{\\?} sends you the following letter.{newline}“{?PLAYER.GENDER}Madam{?}Sir{\\?}, Thank you for looking after my men. You honored our agreement, and you have my gratitude. Please accept this {GOLD}{GOLD_ICON}.”", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					textObject.SetTextVariable("GOLD", this.RewardGold);
					textObject.SetTextVariable("GOLD_ICON", "{=!}<img src=\"General\\Icons\\Coin@2x\" extend=\"8\">");
					return textObject;
				}
			}

			// Token: 0x17001085 RID: 4229
			// (get) Token: 0x06004F4C RID: 20300 RVA: 0x00169E54 File Offset: 0x00168054
			private TextObject _partialSuccessLog
			{
				get
				{
					TextObject textObject = new TextObject("{=yjAHh66a}You managed to return more than half of the troops {QUEST_GIVER.LINK} gave you to train. {?QUEST_GIVER.GENDER}She{?}He{\\?} sends you the following letter. {newline}“{?PLAYER.GENDER}Madam{?}Sir{\\?}, Thank you for returning my men to me. The losses they suffered are somewhat higher than I thought. I can only hope you did what you could to honor our agreement and try to keep them alive.”", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x17001086 RID: 4230
			// (get) Token: 0x06004F4D RID: 20301 RVA: 0x00169E88 File Offset: 0x00168088
			private TextObject _weakSuccessLog
			{
				get
				{
					TextObject textObject = new TextObject("{=NXs7kr2B}You managed to return a fraction of the troops {QUEST_GIVER.LINK} gave you to train. {?QUEST_GIVER.GENDER}She{?}He{\\?} sends you the following letter. {newline}“{?PLAYER.GENDER}Madam{?}Sir{\\?}, Thank you for returning my men to me. The losses they suffered are somewhat higher than I thought. I can only hope you did what you could do to honor our agreement and try to keep them alive.”", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x17001087 RID: 4231
			// (get) Token: 0x06004F4E RID: 20302 RVA: 0x00169EBC File Offset: 0x001680BC
			private TextObject _failLog
			{
				get
				{
					TextObject textObject = new TextObject("{=YBEB7GLa}All the borrowed troops in your party are gone. You are unable to return any of the troops {QUEST_GIVER.LINK} gave you to train. {?QUEST_GIVER.GENDER}She{?}He{\\?} sends you the following letter. {newline}“{?PLAYER.GENDER}Madam{?}Sir{\\?}, I understand that all my men are dead. I asked you to try and keep them alive. I do not know what to say to their kinfolk. This is a breach of my trust.”", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x17001088 RID: 4232
			// (get) Token: 0x06004F4F RID: 20303 RVA: 0x00169EF0 File Offset: 0x001680F0
			private TextObject _epicFailLog
			{
				get
				{
					TextObject textObject = new TextObject("{=eSpRuda1}You have decided to keep the borrowed troops {QUEST_GIVER.LINK} gave you to train. When {?QUEST_GIVER.GENDER}She{?}He{\\?} hears about this {?QUEST_GIVER.GENDER}she{?}he{\\?} sends you the following letter. {newline}“{?PLAYER.GENDER}Madam{?}Sir{\\?}, I made it clear that I expected my men to be returned to me. I consider this a betrayal of my trust.”", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x17001089 RID: 4233
			// (get) Token: 0x06004F50 RID: 20304 RVA: 0x00169F24 File Offset: 0x00168124
			private TextObject _cancelLogOnWarDeclared
			{
				get
				{
					TextObject textObject = new TextObject("{=TrewB5c7}Now your {?IS_MAP_FACTION}clan{?}kingdom{\\?} is at war with the {QUEST_GIVER.LINK}'s lord. Your agreement with {QUEST_GIVER.LINK} becomes invalid.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					textObject.SetTextVariable("IS_MAP_FACTION", Clan.PlayerClan.IsMapFaction ? 1 : 0);
					return textObject;
				}
			}

			// Token: 0x1700108A RID: 4234
			// (get) Token: 0x06004F51 RID: 20305 RVA: 0x00169F74 File Offset: 0x00168174
			private TextObject _playerDeclaredWarQuestLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=bqeWVVEE}Your actions have started a war with {QUEST_GIVER.LINK}'s faction. {?QUEST_GIVER.GENDER}She{?}He{\\?} cancels your agreement and the quest is a failure.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x1700108B RID: 4235
			// (get) Token: 0x06004F52 RID: 20306 RVA: 0x00169FA8 File Offset: 0x001681A8
			private TextObject _timeoutLog
			{
				get
				{
					TextObject textObject = new TextObject("{=txtsL6QQ}You failed to train the troops by the time {QUEST_GIVER.LINK} needed them back. {?QUEST_GIVER.GENDER}She{?}He{\\?} sends you the following letter. “{?PLAYER.GENDER}Madam{?}Sir{\\?}, I expected my men to be returned to me. I consider this a breach of our agreement.”", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x1700108C RID: 4236
			// (get) Token: 0x06004F53 RID: 20307 RVA: 0x00169FDA File Offset: 0x001681DA
			private TextObject _crimeLog
			{
				get
				{
					TextObject textObject = new TextObject("{=faZuFQUF}You are accused in {SETTLEMENT} of a crime, and {QUEST_GIVER.LINK} no longer wants your help.", null);
					textObject.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, false);
					textObject.SetTextVariable("SETTLEMENT", base.QuestGiver.CurrentSettlement.Name);
					return textObject;
				}
			}

			// Token: 0x1700108D RID: 4237
			// (get) Token: 0x06004F54 RID: 20308 RVA: 0x0016A01A File Offset: 0x0016821A
			public override TextObject Title
			{
				get
				{
					TextObject textObject = new TextObject("{=q2aed7tv}Train troops for {ISSUE_OWNER.NAME}", null);
					textObject.SetCharacterProperties("ISSUE_OWNER", base.QuestGiver.CharacterObject, false);
					return textObject;
				}
			}

			// Token: 0x1700108E RID: 4238
			// (get) Token: 0x06004F55 RID: 20309 RVA: 0x0016A03E File Offset: 0x0016823E
			public override bool IsRemainingTimeHidden
			{
				get
				{
					return false;
				}
			}

			// Token: 0x06004F56 RID: 20310 RVA: 0x0016A041 File Offset: 0x00168241
			public LandlordTrainingForRetainersIssueQuest(string questId, Hero giverHero, CampaignTime duration, float difficultyMultiplier, int rewardGold) : base(questId, giverHero, duration, rewardGold)
			{
				this._difficultyMultiplier = difficultyMultiplier;
				this.SetDialogs();
				base.InitializeQuestOnCreation();
			}

			// Token: 0x06004F57 RID: 20311 RVA: 0x0016A064 File Offset: 0x00168264
			protected override void InitializeQuestOnGameLoad()
			{
				this._questGivenChar = MBObjectManager.Instance.GetObject<CharacterObject>("borrowed_troop");
				this._questGivenChar.SetTransferableInPartyScreen(false);
				this._questTargetChar = MBObjectManager.Instance.GetObject<CharacterObject>("veteran_borrowed_troop");
				this._questTargetChar.SetTransferableInPartyScreen(false);
				if (this._playerStartsQuestLog == null)
				{
					this._playerStartsQuestLog = base.JournalEntries.First<JournalLog>();
					base.UpdateQuestTaskStage(this._playerStartsQuestLog, PartyBase.MainParty.MemberRoster.GetTroopCount(this._questTargetChar));
				}
				this.SetDialogs();
			}

			// Token: 0x06004F58 RID: 20312 RVA: 0x0016A0F4 File Offset: 0x001682F4
			protected override void RegisterEvents()
			{
				CampaignEvents.OnTroopsDesertedEvent.AddNonSerializedListener(this, new Action<MobileParty, TroopRoster>(this.OnTroopsDeserted));
				CampaignEvents.OnPlayerBattleEndEvent.AddNonSerializedListener(this, new Action<MapEvent>(this.OnPlayerBattleEnd));
				CampaignEvents.PlayerUpgradedTroopsEvent.AddNonSerializedListener(this, new Action<CharacterObject, CharacterObject, int>(this.OnPlayerUpgradedTroops));
				CampaignEvents.OnSettlementLeftEvent.AddNonSerializedListener(this, new Action<MobileParty, Settlement>(this.OnSettlementLeft));
				CampaignEvents.WarDeclared.AddNonSerializedListener(this, new Action<IFaction, IFaction, DeclareWarAction.DeclareWarDetail>(this.OnWarDeclared));
				CampaignEvents.OnClanChangedKingdomEvent.AddNonSerializedListener(this, new Action<Clan, Kingdom, Kingdom, ChangeKingdomAction.ChangeKingdomActionDetail, bool>(this.OnClanChangedKingdom));
				CampaignEvents.MapEventStarted.AddNonSerializedListener(this, new Action<MapEvent, PartyBase, PartyBase>(this.OnMapEventStarted));
				CampaignEvents.OnTroopGivenToSettlementEvent.AddNonSerializedListener(this, new Action<Hero, Settlement, TroopRoster>(this.OnTroopGivenToSettlement));
			}

			// Token: 0x06004F59 RID: 20313 RVA: 0x0016A1BC File Offset: 0x001683BC
			protected override void SetDialogs()
			{
				this.OfferDialogFlow = DialogFlow.CreateDialogFlow("issue_classic_quest_start", 100).NpcLine(new TextObject("{=J8qFgwal}Excellent. I'll tell the lads to join your party.[if:convo_relaxed_happy][ib:confident2]", null), null, null).Condition(() => CharacterObject.OneToOneConversationCharacter == base.QuestGiver.CharacterObject).Consequence(new ConversationSentence.OnConsequenceDelegate(this.QuestAcceptedConsequences)).NpcLineWithVariation("{=7lee0h29}One thing - if one or two die, that's the fortunes of war, things could go even worse if we get raided and have no one who can fight back... But try not to get them all massacred. These men will take some risks for me, but not have their lives thrown away to no purpose.[if:convo_stern]", null, null).Variation("{=EaPQ2mm7}One thing - if possible, try not to get them all killed, will you? Green troops aren't much use to me, but corpses are even less.[if:convo_stern]", new object[]
				{
					"UngratefulTag",
					1,
					"MercyTag",
					-1
				}).CloseDialog();
				this.DiscussDialogFlow = DialogFlow.CreateDialogFlow("quest_discuss", 100).NpcLine(new TextObject("{=r9F1W4KZ}Yes? Have you been able to train my men?[if:convo_astonished]", null), null, null).Condition(() => CharacterObject.OneToOneConversationCharacter == base.QuestGiver.CharacterObject).BeginPlayerOptions().PlayerOption(new TextObject("{=PVO3YFSq}Yes we are heading out now.", null), null).NpcLine(new TextObject("{=weW40mKG}Good to hear that! Safe journeys.[if:convo_relaxed_happy]", null), null, null).CloseDialog().PlayerOption(new TextObject("{=wErSpkjy}I'm still working on it.", null), null).NpcLine(new TextObject("{=weW40mKG}Good to hear that! Safe journeys.[if:convo_relaxed_happy]", null), null, null).CloseDialog().EndPlayerOptions().CloseDialog();
			}

			// Token: 0x06004F5A RID: 20314 RVA: 0x0016A2E8 File Offset: 0x001684E8
			private void QuestAcceptedConsequences()
			{
				base.StartQuest();
				this._questGivenChar = MBObjectManager.Instance.GetObject<CharacterObject>("borrowed_troop");
				this._questGivenChar.SetTransferableInPartyScreen(false);
				this._questTargetChar = MBObjectManager.Instance.GetObject<CharacterObject>("veteran_borrowed_troop");
				this._questTargetChar.SetTransferableInPartyScreen(false);
				PartyBase.MainParty.AddElementToMemberRoster(this._questGivenChar, this._borrowedTroopCount, false);
				PartyBase.MainParty.ItemRoster.AddToCounts(DefaultItems.Grain, 3);
				this._playerStartsQuestLog = base.AddDiscreteLog(this._questStartLog, new TextObject("{=wUb5h4a3}Trained Troops", null), PartyBase.MainParty.MemberRoster.GetTroopCount(this._questTargetChar), this._borrowedTroopCount, null, false);
			}

			// Token: 0x06004F5B RID: 20315 RVA: 0x0016A3A5 File Offset: 0x001685A5
			private void OnPlayerBattleEnd(MapEvent mapEvent)
			{
				if (mapEvent.IsPlayerMapEvent)
				{
					this.CheckFail();
				}
			}

			// Token: 0x06004F5C RID: 20316 RVA: 0x0016A3B6 File Offset: 0x001685B6
			private void OnTroopsDeserted(MobileParty mobileParty, TroopRoster desertedTroops)
			{
				if (mobileParty.IsMainParty)
				{
					this.CheckFail();
				}
			}

			// Token: 0x06004F5D RID: 20317 RVA: 0x0016A3C8 File Offset: 0x001685C8
			private void OnPlayerUpgradedTroops(CharacterObject upgradeFromTroop, CharacterObject upgradeToTroop, int number)
			{
				if (upgradeFromTroop == this._questGivenChar && upgradeToTroop == this._questTargetChar && number > 0)
				{
					base.UpdateQuestTaskStage(this._playerStartsQuestLog, PartyBase.MainParty.MemberRoster.GetTroopCount(this._questTargetChar));
				}
				if (!this.CheckFail())
				{
					this.CheckSuccess(false);
				}
			}

			// Token: 0x06004F5E RID: 20318 RVA: 0x0016A41B File Offset: 0x0016861B
			private void OnSettlementLeft(MobileParty party, Settlement settlement)
			{
				if (!this.CheckFail())
				{
					this.CheckSuccess(false);
				}
			}

			// Token: 0x06004F5F RID: 20319 RVA: 0x0016A42C File Offset: 0x0016862C
			protected override void HourlyTick()
			{
				if (base.IsOngoing && !this.CheckFail())
				{
					this.CheckSuccess(false);
				}
			}

			// Token: 0x06004F60 RID: 20320 RVA: 0x0016A448 File Offset: 0x00168648
			private void OnMapEventStarted(MapEvent mapEvent, PartyBase attackerParty, PartyBase defenderParty)
			{
				if ((mapEvent.IsForcingSupplies || mapEvent.IsForcingVolunteers || mapEvent.IsRaid) && attackerParty == PartyBase.MainParty && mapEvent.MapEventSettlement.IsVillage && mapEvent.MapEventSettlement == base.QuestGiver.CurrentSettlement)
				{
					this.CriminalActionPerformedTowardsSettlement();
				}
			}

			// Token: 0x06004F61 RID: 20321 RVA: 0x0016A49B File Offset: 0x0016869B
			private void OnTroopGivenToSettlement(Hero giverHero, Settlement recipientSettlement, TroopRoster roster)
			{
				if (giverHero == Hero.MainHero && !this.CheckFail())
				{
					this.CheckSuccess(false);
				}
			}

			// Token: 0x06004F62 RID: 20322 RVA: 0x0016A4B4 File Offset: 0x001686B4
			private void OnClanChangedKingdom(Clan clan, Kingdom oldKingdom, Kingdom newKingdom, ChangeKingdomAction.ChangeKingdomActionDetail detail, bool showNotification = true)
			{
				if (base.QuestGiver.CurrentSettlement.MapFaction.IsAtWarWith(Hero.MainHero.MapFaction))
				{
					base.CompleteQuestWithCancel(this._cancelLogOnWarDeclared);
				}
			}

			// Token: 0x06004F63 RID: 20323 RVA: 0x0016A4E3 File Offset: 0x001686E3
			private void OnWarDeclared(IFaction faction1, IFaction faction2, DeclareWarAction.DeclareWarDetail detail)
			{
				QuestHelper.CheckWarDeclarationAndFailOrCancelTheQuest(this, faction1, faction2, detail, this._playerDeclaredWarQuestLogText, this._cancelLogOnWarDeclared, false);
			}

			// Token: 0x06004F64 RID: 20324 RVA: 0x0016A4FC File Offset: 0x001686FC
			private void RemoveBorrowedTroopsFromParty(PartyBase party)
			{
				int troopCount = party.MemberRoster.GetTroopCount(this._questTargetChar);
				if (troopCount > 0)
				{
					party.MemberRoster.AddToCounts(this._questTargetChar, -troopCount, false, 0, 0, true, -1);
				}
				int troopCount2 = party.MemberRoster.GetTroopCount(this._questGivenChar);
				if (troopCount2 > 0)
				{
					party.MemberRoster.AddToCounts(this._questGivenChar, -troopCount2, false, 0, 0, true, -1);
				}
			}

			// Token: 0x06004F65 RID: 20325 RVA: 0x0016A568 File Offset: 0x00168768
			private void TurnRemainingQuestTroopsIntoNormalTroops(PartyBase party)
			{
				int elementNumber = party.MemberRoster.GetElementNumber(this._questGivenChar);
				int elementNumber2 = party.MemberRoster.GetElementNumber(this._questTargetChar);
				int elementNumber3 = party.PrisonRoster.GetElementNumber(this._questGivenChar);
				int elementNumber4 = party.PrisonRoster.GetElementNumber(this._questTargetChar);
				if (elementNumber > 0)
				{
					party.MemberRoster.AddToCounts(this._questGivenChar, -elementNumber, false, 0, 0, true, -1);
					party.MemberRoster.AddToCounts(base.QuestGiver.Culture.BasicTroop, elementNumber, false, 0, 0, true, -1);
				}
				if (elementNumber2 > 0)
				{
					party.MemberRoster.AddToCounts(this._questTargetChar, -elementNumber2, false, 0, 0, true, -1);
					party.MemberRoster.AddToCounts(base.QuestGiver.Culture.EliteBasicTroop, elementNumber2, false, 0, 0, true, -1);
				}
				if (elementNumber3 > 0)
				{
					party.PrisonRoster.AddToCounts(this._questGivenChar, -elementNumber3, false, 0, 0, true, -1);
					party.PrisonRoster.AddToCounts(base.QuestGiver.Culture.BasicTroop, elementNumber3, false, 0, 0, true, -1);
				}
				if (elementNumber4 > 0)
				{
					party.PrisonRoster.AddToCounts(this._questTargetChar, -elementNumber4, false, 0, 0, true, -1);
					party.PrisonRoster.AddToCounts(base.QuestGiver.Culture.EliteBasicTroop, elementNumber4, false, 0, 0, true, -1);
				}
			}

			// Token: 0x06004F66 RID: 20326 RVA: 0x0016A6B9 File Offset: 0x001688B9
			private bool CheckFail()
			{
				if (PartyBase.MainParty.MemberRoster.GetTroopCount(this._questTargetChar) == 0 && PartyBase.MainParty.MemberRoster.GetTroopCount(this._questGivenChar) == 0)
				{
					this.Fail();
					return true;
				}
				return false;
			}

			// Token: 0x06004F67 RID: 20327 RVA: 0x0016A6F4 File Offset: 0x001688F4
			private void CheckSuccess(bool isConversationEnded = false)
			{
				if (PartyBase.MainParty.MemberRoster.GetTroopCount(this._questGivenChar) == 0 && PartyBase.MainParty.MemberRoster.GetTroopCount(this._questTargetChar) > 0 && !this._popUpOpened && (Campaign.Current.ConversationManager.OneToOneConversationHero == null || isConversationEnded))
				{
					this.OpenDecisionPopUp();
				}
			}

			// Token: 0x06004F68 RID: 20328 RVA: 0x0016A754 File Offset: 0x00168954
			private void OpenDecisionPopUp()
			{
				this._popUpOpened = true;
				this._campaignTimeControlModeCacheForDecisionPopUp = Campaign.Current.TimeControlMode;
				Campaign.Current.TimeControlMode = CampaignTimeControlMode.Stop;
				TextObject textObject = new TextObject("{=LO7EjoY7}The borrowed troops remaining in your party are now all experienced. You can send them back to {QUEST_GIVER.LINK}.", null);
				StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
				InformationManager.ShowInquiry(new InquiryData("", textObject.ToString(), true, true, new TextObject("{=ikDX1Fd7}Send the troops back", null).ToString(), new TextObject("{=yFahppU2}Hold on to them", null).ToString(), new Action(this.CompleteQuestSuccessfully), new Action(this.EpicFail), "", 0f, null, null, null), false, false);
			}

			// Token: 0x06004F69 RID: 20329 RVA: 0x0016A808 File Offset: 0x00168A08
			private void CompleteQuestSuccessfully()
			{
				Campaign.Current.TimeControlMode = this._campaignTimeControlModeCacheForDecisionPopUp;
				int troopCount = PartyBase.MainParty.MemberRoster.GetTroopCount(this._questTargetChar);
				PartyBase.MainParty.MemberRoster.AddToCounts(this._questTargetChar, -troopCount, false, 0, 0, true, -1);
				int troopCount2 = PartyBase.MainParty.MemberRoster.GetTroopCount(this._questGivenChar);
				PartyBase.MainParty.MemberRoster.AddToCounts(this._questGivenChar, -troopCount2, false, 0, 0, true, -1);
				if (troopCount >= this._borrowedTroopCount)
				{
					this.TotalSuccess();
					return;
				}
				if ((float)this._borrowedTroopCount * 0.5f < (float)troopCount && troopCount < this._borrowedTroopCount)
				{
					this.PartialSuccess();
					return;
				}
				if (0 < troopCount && (float)troopCount <= (float)this._borrowedTroopCount * 0.5f)
				{
					this.WeakSuccess();
				}
			}

			// Token: 0x06004F6A RID: 20330 RVA: 0x0016A8D8 File Offset: 0x00168AD8
			private void TotalSuccess()
			{
				Clan.PlayerClan.AddRenown(2f, true);
				this.RelationshipChangeWithQuestGiver = 5;
				TraitLevelingHelper.OnIssueSolvedThroughQuest(base.QuestGiver, new Tuple<TraitObject, int>[]
				{
					new Tuple<TraitObject, int>(DefaultTraits.Honor, 50)
				});
				GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, this.RewardGold, false);
				base.QuestGiver.AddPower(10f);
				base.AddLog(this._totalSuccessLog, false);
				base.CompleteQuestWithSuccess();
			}

			// Token: 0x06004F6B RID: 20331 RVA: 0x0016A954 File Offset: 0x00168B54
			private void PartialSuccess()
			{
				Clan.PlayerClan.AddRenown(1f, true);
				this.RelationshipChangeWithQuestGiver = 3;
				TraitLevelingHelper.OnIssueSolvedThroughQuest(base.QuestGiver, new Tuple<TraitObject, int>[]
				{
					new Tuple<TraitObject, int>(DefaultTraits.Honor, 30)
				});
				GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, this.RewardGold, false);
				base.QuestGiver.AddPower(10f);
				base.AddLog(this._partialSuccessLog, false);
				base.CompleteQuestWithSuccess();
			}

			// Token: 0x06004F6C RID: 20332 RVA: 0x0016A9D0 File Offset: 0x00168BD0
			private void WeakSuccess()
			{
				Clan.PlayerClan.AddRenown(1f, true);
				this.RelationshipChangeWithQuestGiver = 1;
				TraitLevelingHelper.OnIssueSolvedThroughQuest(base.QuestGiver, new Tuple<TraitObject, int>[]
				{
					new Tuple<TraitObject, int>(DefaultTraits.Honor, 10)
				});
				GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, this.RewardGold, false);
				base.QuestGiver.AddPower(10f);
				base.AddLog(this._weakSuccessLog, false);
				base.CompleteQuestWithSuccess();
			}

			// Token: 0x06004F6D RID: 20333 RVA: 0x0016AA4A File Offset: 0x00168C4A
			private void Fail()
			{
				this.RelationshipChangeWithQuestGiver = -5;
				base.QuestGiver.AddPower(-10f);
				base.AddLog(this._failLog, false);
				base.CompleteQuestWithFail(null);
			}

			// Token: 0x06004F6E RID: 20334 RVA: 0x0016AA7C File Offset: 0x00168C7C
			private void EpicFail()
			{
				Campaign.Current.TimeControlMode = this._campaignTimeControlModeCacheForDecisionPopUp;
				this.RelationshipChangeWithQuestGiver = -10;
				base.QuestGiver.AddPower(-10f);
				ChangeCrimeRatingAction.Apply(base.QuestGiver.MapFaction, 10f, true);
				TraitLevelingHelper.OnIssueSolvedThroughQuest(base.QuestGiver, new Tuple<TraitObject, int>[]
				{
					new Tuple<TraitObject, int>(DefaultTraits.Honor, -10)
				});
				base.AddLog(this._epicFailLog, false);
				base.CompleteQuestWithFail(null);
			}

			// Token: 0x06004F6F RID: 20335 RVA: 0x0016AAFC File Offset: 0x00168CFC
			private void CriminalActionPerformedTowardsSettlement()
			{
				this.RelationshipChangeWithQuestGiver = -5;
				base.QuestGiver.AddPower(-10f);
				Tuple<TraitObject, int>[] effectedTraits = new Tuple<TraitObject, int>[]
				{
					new Tuple<TraitObject, int>(DefaultTraits.Honor, -50)
				};
				TraitLevelingHelper.OnIssueSolvedThroughQuest(Hero.MainHero, effectedTraits);
				base.CompleteQuestWithFail(this._crimeLog);
			}

			// Token: 0x06004F70 RID: 20336 RVA: 0x0016AB50 File Offset: 0x00168D50
			protected override void OnFinalize()
			{
				this._questGivenChar = MBObjectManager.Instance.GetObject<CharacterObject>("borrowed_troop");
				this._questTargetChar = MBObjectManager.Instance.GetObject<CharacterObject>("veteran_borrowed_troop");
				foreach (MobileParty mobileParty in MobileParty.All.ToList<MobileParty>())
				{
					if (!mobileParty.IsMilitia)
					{
						this.TurnRemainingQuestTroopsIntoNormalTroops(mobileParty.Party);
					}
				}
			}

			// Token: 0x06004F71 RID: 20337 RVA: 0x0016ABE0 File Offset: 0x00168DE0
			protected override void OnBeforeTimedOut(ref bool completeWithSuccess, ref bool doNotResolveTheQuest)
			{
				if (PartyBase.MainParty.MemberRoster.GetTroopCount(this._questTargetChar) > 0)
				{
					doNotResolveTheQuest = true;
					if (!this._popUpOpened && MobileParty.MainParty.MapEvent == null)
					{
						this.OpenDecisionPopUp();
					}
				}
			}

			// Token: 0x06004F72 RID: 20338 RVA: 0x0016AC17 File Offset: 0x00168E17
			protected override void OnTimedOut()
			{
				this.RelationshipChangeWithQuestGiver = -5;
				base.QuestGiver.AddPower(-10f);
				this.RemoveBorrowedTroopsFromParty(PartyBase.MainParty);
				base.AddLog(this._timeoutLog, false);
			}

			// Token: 0x04001A45 RID: 6725
			private bool _popUpOpened;

			// Token: 0x04001A46 RID: 6726
			private CharacterObject _questGivenChar;

			// Token: 0x04001A47 RID: 6727
			private CharacterObject _questTargetChar;

			// Token: 0x04001A48 RID: 6728
			[SaveableField(1)]
			private readonly float _difficultyMultiplier;

			// Token: 0x04001A49 RID: 6729
			private CampaignTimeControlMode _campaignTimeControlModeCacheForDecisionPopUp;

			// Token: 0x04001A4A RID: 6730
			[SaveableField(2)]
			private JournalLog _playerStartsQuestLog;
		}

		// Token: 0x02000646 RID: 1606
		public class LandlordTrainingForRetainersIssueTypeDefiner : SaveableTypeDefiner
		{
			// Token: 0x06004F75 RID: 20341 RVA: 0x0016AC72 File Offset: 0x00168E72
			public LandlordTrainingForRetainersIssueTypeDefiner() : base(410000)
			{
			}

			// Token: 0x06004F76 RID: 20342 RVA: 0x0016AC7F File Offset: 0x00168E7F
			protected override void DefineClassTypes()
			{
				base.AddClassDefinition(typeof(LandlordTrainingForRetainersIssueBehavior.LandlordTrainingForRetainersIssue), 1, null);
				base.AddClassDefinition(typeof(LandlordTrainingForRetainersIssueBehavior.LandlordTrainingForRetainersIssueQuest), 2, null);
			}
		}
	}
}
